<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script type="text/javascript">
        // 分为两类：其实就是两个js对象，sessionStorage,localStorage
        // sessionStorage:存放的数据只在当前窗口有效。
// localStorage：持久化存储。只要不删除，在当前浏览器永远有效
        function add() {

            localStorage.setItem("user","zs");
        }
        function del() {

            localStorage.removeItem("user")
        }
        function update() {
            localStorage.setItem("user","zs-edit");
        }
        function get() {
            alert(localStorage.getItem("user"))
        }
    </script>
</head>
<body>

<button type="button" onclick="add()"> add</button>
<button type="button" onclick="del()"> del</button>
<button type="button" onclick="update()"> update</button>
<button type="button" onclick="get()"> get</button>

</body>
</html>